""" -*- coding: utf-8 -*-
 @Time    : 2019/1/24 21:42
 @Author  : 木鱼
 @File    : __init__.py.py
 @Software: PyCharm
"""
from .app import Flask


# 将 redprint 注册到 blueprint
def register_blueprints(app):
    from app.api.v1 import create_blueprint
    app.register_blueprint(create_blueprint(), url_prefix='/v1')


# 数据库
def register_plugin(app):
    from app.models.base import db
    db.init_app(app)
    with app.app_context():
        db.create_all()


def create_app():
    app = Flask(__name__)
    app.config.from_object('app.config.setting')
    app.config.from_object('app.config.secure')

    register_blueprints(app)
    register_plugin(app)

    return app
